<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var str = "1,2,3,5"

        function fun(str, value) {
            var num = str.length - 1
            console.log(str.charAt(num) == value ? true : false)
        }
        fun("1,2,3,5", 5)
    </script>
</body>

</html>